﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="原料出库单录入.aspx.cs" Inherits="syc.Store.原料出库单录入" %>
<html>
<head>
<title></title>
</head>
<body>
<script type="text/javascript" language="javascript" src="/common.js"></script>
<form id="form1" runat="server" onsubmit="return checkinput();">

<asp:Label ID="IsReadonly" runat="server" Text="false" Visible="false"></asp:Label>
<asp:Label ID="LockSum" runat="server" Text="false" Visible="false"></asp:Label>

<asp:Label ID="Label_ID" runat="server" Text="0" Visible="false"></asp:Label>
<asp:Label ID="Label_List" runat="server" Text="" Visible="false"></asp:Label>
<asp:HiddenField ID="BeiZhu" runat="server" />

<asp:HiddenField ID="ZSList" runat="server" />
<asp:HiddenField ID="ZLList" runat="server" />
<asp:HiddenField ID="DJList" runat="server" />


<div id="wintop" class="wintop">原料出库单录入</div>
<asp:Panel ID="Panel1" runat="server" CssClass="panel">
<!-- =================================================================================================== -->
<!-- ========                               原料类别列表                                     =========== -->
<!-- ========                                                                               =========== -->
<!-- =================================================================================================== -->
<asp:SqlDataSource ID="DS_LeiBie" runat="server" 
                   ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>" 
                    SelectCommand="SELECT [ID],[品名]+' '+[钢级]+' '+[规格] AS 名称 FROM [原料]" >
</asp:SqlDataSource>
原料：
<asp:DropDownList ID="LeiBie" runat="server" Width="250px" Font-Size="12px" DataSourceID="DS_LeiBie" 
                               DataTextField="名称" DataValueField="ID">
</asp:DropDownList>
<!-- =================================================================================================== -->
<asp:RadioButtonList ID="DanWei" runat="server" RepeatDirection="Horizontal" 
        RepeatLayout="Flow">
        <asp:ListItem Selected="True">吨</asp:ListItem>
        <asp:ListItem>支</asp:ListItem>
    </asp:RadioButtonList>
    
<span style="margin-left:6px;"></span>分厂：<asp:DropDownList 
    ID="GongHuo" Width="120px" runat="server">
    <asp:ListItem Text="一分厂" Value="1"></asp:ListItem>
    <asp:ListItem Text="二分厂" Value="2"></asp:ListItem>
    <asp:ListItem Text="三分厂" Value="3"></asp:ListItem>
    <asp:ListItem Text="四分厂" Value="4"></asp:ListItem>
    <asp:ListItem Text="五分厂" Value="5"></asp:ListItem>
</asp:DropDownList>
    <asp:Button ID="Button_Save" runat="server" Text="保 存" class="button" 
        UseSubmitBehavior="false" onclick="Button_Save_Click"/>
    <input type="button" value="关 闭" class="button" onclick="parent.swin2_close();" />
</asp:Panel>
<asp:Panel ID="Panel2" runat="server" CssClass="panel">
日期：<asp:TextBox ID="Date1" runat="server" CssClass="textbox" Width="100"></asp:TextBox><img alt="" src="/Icons/29.png" align="middle" onclick="makecalendar(document.getElementById('Date1').value, document.getElementById('Date1'));" />
<span style="margin-left:6px;"></span>单号：<asp:TextBox ID="DanHao" runat="server" CssClass="textbox" Width="80"></asp:TextBox>
<span style="margin-left:30px;"></span>总支数：<asp:TextBox ID="ZZS" runat="server" CssClass="textbox" Width="80" Enabled="false" Text="0" BackColor="#dddddd"></asp:TextBox>支
<span style="margin-left:6px;"></span>总重量：<asp:TextBox ID="ZZL" runat="server" CssClass="textbox" Width="80" Enabled="false" Text="0" BackColor="#dddddd"></asp:TextBox>吨
</asp:Panel>
<asp:Panel ID="Panel3" runat="server">
<script>putBillHead();</script>
<style>
td.bb,td.ed{border:.5pt solid black;}
td.ed{background-color:#d2e8ae;}
span.ed{display:inline-block;width:100%;height:100%;line-height:26px;overflow:hidden;background-color:#d2e8ae;}

</style>
<table id="mt" border="0" cellpadding="0" style="border-collapse: collapse;text-align:center;font-size:14px;">
	<tr height="30">
		<td colspan="8" style="font-size:20px;"><b>专用原（辅）料出库单</b></td>
	</tr>
	<tr height="20">
		<td colspan="8" align="left" style="padding-left:10px;">编码：SYC/ZJ-WL-13</td>
	</tr>
	<tr height="20">
		<td colspan="2" align="left" style="padding-left:10px;">使用单位：<span id=Label_GongHuo></span></td>
		<td colspan="3" id=Label_Date></td>
		<td colspan="3" align="right" style="color:red;padding-right:10px;">No.<span id=Label_DanHao></span></td>
	</tr>
	<tr>
		<td width="120" class=bb height="32">材料名称(钢级)</td>
		<td width="100" class=bb>规 格</td>
		<td width="80" class=bb>批次(编号)</td>
		<td width="50" class=bb>单 位</td>
		<td width="70" class=bb>数 量</td>
		<td width="70" class=bb>重 量</td>
		<td width="90" class=bb>单 价</td>
		<td width="100" class=bb>金 额</td>
	</tr>
	<tr>
		<td class=bb height="26" id=Label_LeiBie></td>
		<td class=bb></td>
		<td class=bb></td>
		<td class=bb id=Label_DanWei></td>
		<td class=bb><span id=dd11 class=ed></span></td>
		<td class=bb><span id=dd12 class=ed></span></td>
		<td class=bb><span id=dd13 class=ed></span></td>
		<td class=bb id=dd14></td>
	</tr>
	<tr>
		<td class=bb height="26"></td>
		<td class=bb></td>
		<td class=bb></td>
		<td class=bb></td>
		<td class=bb><span id=dd21 class=ed></span></td>
		<td class=bb><span id=dd22 class=ed></span></td>
		<td class=bb><span id=dd23 class=ed></span></td>
		<td class=bb id=dd24></td>
	</tr>
	<tr>
		<td class=bb height="26"></td>
		<td class=bb></td>
		<td class=bb></td>
		<td class=bb></td>
		<td class=bb><span id=dd31 class=ed></span></td>
		<td class=bb><span id=dd32 class=ed></span></td>
		<td class=bb><span id=dd33 class=ed></span></td>
		<td class=bb id=dd34></td>
	</tr>
	<tr>
		<td class=bb height="26"></td>
		<td class=bb></td>
		<td class=bb></td>
		<td class=bb></td>
		<td class=bb><span id=dd41 class=ed></span></td>
		<td class=bb><span id=dd42 class=ed></span></td>
		<td class=bb><span id=dd43 class=ed></span></td>
		<td class=bb id=dd44></td>
	</tr>
	<tr>
		<td class=bb height="26">备注</td>
		<td class=bb colspan=7 style="text-align:left;"><span id=Label_BeiZhu class=ed></span></td>
	</tr>
	<tr height="26">
		<td colspan="8" align="left">
		<span style="display:inline-block;width:160px;margin-left:15px;">仓储主管：</span>
		<span style="display:inline-block;width:150px;margin-left:5px;">保管员：</span>
		<span style="display:inline-block;width:170px;margin-left:5px;">使用单位主管：</span>
		<span style="display:inline-block;width:150px;margin-left:5px;">领用人：</span>		
		</td>
	</tr>
</table>

<script>putBillFoot();</script>

</asp:Panel>

</form>
<script>
var notice = "<%=this.Notice %>";//提示信息
    var readonly = <%=this.IsReadonly.Text %>;
    var locksum = <%=this.LockSum.Text %>;
    if (notice != "") {
        parent.showmsgbox(notice);
    }
</script>
<script>
    var mt = document.getElementById("mt"); //主表格
    var i;
    function calc() {
        var n,zl,zs;
        var zzl = 0;
        var zzs = 0;
        for (i = 1; i <= 4; i++) {

            zs = Number(document.getElementById("dd" + i + "1").innerHTML);
            zl = Number(document.getElementById("dd" + i + "2").innerHTML);
            if (zs != 0 && !isNaN(zs)) {
                zzs += zs;
            }
            if (zl != 0 && !isNaN(zl)) {
                zzl += zl;
            }
            if (document.getElementById("DanWei_0").checked) {
                n = Number(document.getElementById("dd" + i + "2").innerHTML) * Number(document.getElementById("dd" + i + "3").innerHTML);
            }
            else {
                n = Number(document.getElementById("dd" + i + "1").innerHTML) * Number(document.getElementById("dd" + i + "3").innerHTML);
            }
            if (n != 0 && !isNaN(n)) {
                document.getElementById("dd" + i + "4").innerHTML = fixFloat(n, 2);
            }
        }
        if (!locksum) {
            document.getElementById("ZZS").value = zzs;
            document.getElementById("ZZL").value = fixFloat(zzl,3);
        }
    }
    function init() {
//        document.getElementById("FenChang").onchange = function() {
//            document.getElementById("box_FenChang").innerHTML = "生产单位：" + this.options[this.selectedIndex].text;
        //        };

        document.getElementById("GongHuo").onchange = function() {
            document.getElementById("Label_GongHuo").innerHTML = this.options[this.selectedIndex].text;
        };
        document.getElementById("GongHuo").onchange();
        document.getElementById("LeiBie").onchange = function() {
        document.getElementById("Label_LeiBie").innerHTML = this.options[this.selectedIndex].text;
        };
        document.getElementById("LeiBie").onchange();
        document.getElementById("Date1").onchange = function() {
            document.getElementById("Label_Date").innerHTML = this.value;
        };
        document.getElementById("Date1").onchange();

        document.getElementById("DanHao").onchange = function() {
            document.getElementById("Label_DanHao").innerHTML = "000000".substr(this.value.length) + this.value;
        };
        document.getElementById("DanHao").onchange();

        document.getElementById("DanWei_0").onclick = document.getElementById("DanWei_1").onclick = function() {
            document.getElementById("Label_DanWei").innerHTML = document.getElementById("DanWei_0").checked == true ? "吨" : "支";
            calc();
        };
        document.getElementById("DanWei_0").onclick();
        var spans = document.getElementsByTagName("span");
        if (readonly) {//只读处理
            for (i = 0; i < spans.length; i++) {
                if (spans[i].className == "ed") {
                    spans[i].className = "";
                }
            }
        }
        else {//使之可编辑
            for (i = 0; i < spans.length; i++) {
                if (spans[i].className == "ed") {
                    spans[i].contentEditable = true;
                    //spans[i].tabIndex = 1;
                }
            }
        }
        var zslist = document.getElementById("ZSList").value.split("|");
        var zllist = document.getElementById("ZLList").value.split("|");
        var djlist = document.getElementById("DJList").value.split("|");

        for (i = 1; i <= 4; i++) {
            if (zslist.length >= i) {
                document.getElementById("dd" + i + "1").innerHTML = zslist[i - 1];
            }
            if (zllist.length >= i) {
                document.getElementById("dd" + i + "2").innerHTML = zllist[i - 1];
            }
            if (djlist.length >= i) {
                document.getElementById("dd" + i + "3").innerHTML = djlist[i - 1];
            }
        }
        document.getElementById("Label_BeiZhu").innerHTML = document.getElementById("BeiZhu").value;
        calc();
    }
    init();



    //按键处理
    document.onkeydown = function(e) {
        var o;
        if (!e) e = window.event;
        var tag = e.srcElement;
        if (!tag) tag = e.target;
        if (tag.tagName == "INPUT" && tag.className == "textbox" || tag.tagName == "SELECT" || tag.tagName == "SPAN" || tag.tagName == "DIV") {
            if (e.keyCode == 13) {
                if (tag.id == "Label_BeiZhu") {
                    return false;
                }
                else {
                    e.keyCode = 9; //跳到下一格
                }
            }
        }
        else if (e.keyCode == 8) {
            return false;
        }
    }

    //编辑后检测
    document.onfocusout = function(e) {
        if (!e) e = window.event;
        var tag = e.srcElement;
        if (!tag) tag = e.target;

        if (tag.tagName == "SPAN" && tag.parentNode.tagName == "TD") {
            if (tag.id.substr(0, 2) == "dd") {
                calc();
            }

        }
    }

    //提交前检测
    function checkinput() {
        var o = document.getElementById("DanHao");
        if (o.value == "") {
            parent.showmsgbox("“单号”必须填写。");
            return false;
        }
        else if (o.value.match(/[^0-9]/)) {
            parent.showmsgbox("“单号”只能录入正数。");
            return false;
        }

        document.getElementById("BeiZhu").value = document.getElementById("Label_BeiZhu").innerText;

        var zslist = new Array();
        var zllist = new Array();
        var djlist = new Array();
        var k = 0;
        for (i = 1; i <= 4; i++) {
            if (document.getElementById("dd" + i + "4").innerText != "") {
                zslist[k] = document.getElementById("dd" + i + "1").innerText;
                zllist[k] = document.getElementById("dd" + i + "2").innerText;
                djlist[k] = document.getElementById("dd" + i + "3").innerText;
                k++;
            }
        }

        document.getElementById("ZSList").value = zslist.join("|");
        document.getElementById("ZLList").value = zllist.join("|");
        document.getElementById("DJList").value = djlist.join("|");

        return true;
    }


    //导出Excel
    function Export() {
        var code = document.getElementById("mt").outerHTML;
        form2.content.value =
"<html xmlns:o='urn:schemas-microsoft-com:office:office'\nxmlns:x='urn:schemas-microsoft-com:office:excel'\nxmlns='http://www.w3.org/TR/REC-html40'>\n<head>\n<meta http-equiv=Content-Type content='text/html; charset=utf-8'>\n<style>\n<!--table\n@page\n{mso-header-data:;\nmso-footer-data:;\nmargin:.79in .12in .59in .12in;\nmso-header-margin:.51in;\nmso-footer-margin:.51in;\nmso-horizontal-page-align:center;}\ntd{mso-number-format:'\@';}\ntd.ed,td.gh,td.bb{border:.5pt solid black;font-size:10pt;text-align:center;height:24px;padding:0px;}\ntd.zl{border:.5pt solid black;font-size:10pt;text-align:center;height:24px;padding:0px;mso-number-format:'0\.0_ '}\ntd.cd{border:.5pt solid black;font-size:10pt;text-align:center;height:24px;padding:0px;mso-number-format:'0\.00_ '}\ntd.zs{border:.5pt solid black;font-size:10pt;text-align:center;height:24px;padding:0px;mso-number-format:General}\n-->\n</style>\n<!--[if gte mso 9]><xml>\n<x:ExcelWorkbook>\n<x:ExcelWorksheets>\n<x:ExcelWorksheet>\n<x:Name>产品判定入库通知书</x:Name>\n<x:WorksheetOptions>\n<x:DefaultRowHeight>285</x:DefaultRowHeight>\n<x:Print>\n<x:ValidPrinterInfo/>\n<x:Scale>100</x:Scale>\n<x:PaperSizeIndex>9</x:PaperSizeIndex>\n<x:HorizontalResolution>200</x:HorizontalResolution>\n<x:VerticalResolution>200</x:VerticalResolution>\n</x:Print>\n<x:Selected/>\n<x:Panes>\n<x:Pane>\n<x:Number>3</x:Number>\n<x:ActiveRow>5</x:ActiveRow>\n<x:ActiveCol>0</x:ActiveCol>\n</x:Pane>\n</x:Panes>\n</x:WorksheetOptions>\n</x:ExcelWorksheet>\n</x:ExcelWorkbook>\n</xml><![endif]-->\n</head>\n<body>"
        + code + "</body></html>";
        form2.submit();
    }
</script>
</body>
</html>
